<template>
  <div class="dynamic">
    <div>
      <div v-if="dataList.list">
        截止:{{ dataList.list[0].inputTime | dateFMT }}
      </div>
      <div class="data">
        <el-row :gutter="5">
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>{{ confirmed }}</div>
              <div>累计确诊</div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>{{ suspected }}</div>
              <div>累计疑似</div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>{{ dead }}</div>
              <div>累计死亡</div>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="5">
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>{{ cure }}</div>
              <div>累计治愈</div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>{{ severe }}</div>
              <div>累计重症</div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>{{ outside }}</div>
              <div>累计境外输入</div>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <div>
      <div>国内疫情</div>
      <div class="table_data">
        <el-row>
          <el-col :span="4">
            <div class="grid-content bg-purple">地区</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple-light">确诊</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple">疑似</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple-light">死亡</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple">重症</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple-light">境外输入</div>
          </el-col>
        </el-row>

        <el-row v-for="item in dataList.list" :key="item.id">
          <el-col :span="4">
            <div class="grid-content">{{ item.province }}</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content">{{ item.confirmed }}</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content">{{ item.suspected }}</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content">{{ item.dead }}</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content">{{ item.severe }}</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content">{{ item.outside }}</div>
          </el-col>
        </el-row>
      </div>
    </div>
    <div>
      <div>最新进展</div>
      <div style="background-color: #f8f8f8; padding: 10px">
        <div
          style="margin-bottom: 40px"
          v-for="(item, index) in article.list"
          :key="item.id"
        >
          <div class="logo" v-if="index<=4">
            <div></div>
            <div v-if="index == 0" class="tag">最新</div>
            <div>{{ item.publishTime | dateFMT_ }}</div>
          </div>
          <!-- <div id="title" v-if="index<=4">
            <div id="content" v-html="item.content"></div> -->
            <div
              style="
                background-color: #fff;
                padding: 10px;
                border-radius: 5px;
                cursor: pointer; font-size:25px

              "
            v-html="item.title" v-if="index<=4">
            </div>
             <el-collapse @change="handleChange" v-if="index<=4">
            <el-collapse-item title="">
              <div v-html="item.content"></div>
            </el-collapse-item>
          </el-collapse>
          <!-- </div> -->
          
        </div>
      </div>
       <el-collapse @change="handleChange">
            <el-collapse-item title="更多内容：">
             <div style="background-color: #f8f8f8; padding: 10px">
        <div
          style="margin-bottom: 40px"
          v-for="(item, index) in article.list"
          :key="item.id"
        >
          <div class="logo" v-if="index>4">
            <div></div>
            <!-- <div v-if="index == 0" class="tag">最新</div> -->
            <div style="font-size:16px">{{ item.publishTime | dateFMT_ }}</div>
          </div>
         
            <div
              style="
                background-color: #fff;
                padding: 10px;
                border-radius: 5px;
                cursor: pointer; font-size:25px
              "
            v-html="item.title"  v-if="index>4">
            </div>
            <el-collapse @change="handleChange"  v-if="index>4">
            <el-collapse-item title="">
              <div v-html="item.content"></div>
            </el-collapse-item>
          </el-collapse>
          </div>
          
       
      </div>
            </el-collapse-item>
          </el-collapse>
    </div>
  </div>
</template>
<script>
import { mapActions, mapState, mapGetters } from "vuex";
import moment from "moment";

export default {
  data() {
    return {
      obj: {
        page: 1,
        pageSize: 1000,
      },
    };
  },
  computed: {
    ...mapState("dataList", ["dataList"]),
    ...mapState("article", ["article"]),
    ...mapGetters("dataList", [
      "confirmed",
      "suspected",
      "dead",
      "cure",
      "severe",
      "outside",
    ]),
  },
  created() {
    this.page_query(this.obj);
    this.page_query_article({ page: 1, pageSize: 10 });
  },
  // 过滤器 -处理日期格式
  filters: {
    dateFMT(str) {
      return moment(str).format("YYYY-MM-DD");
    },
    dateFMT_(str) {
      return moment(str).format("YYYY-MM-DD HH:mm:ss");
    },
  },
  methods: {
    ...mapActions("dataList", ["page_query"]),
    ...mapActions("article", ["page_query_article"]),
     handleChange(val) {
        console.log(val);
      }
  },
};
</script>
<style scoped>

.logo div:first-child {
  height: 10px;
  width: 10px;
  border-radius: 50%;
  background-color: #005dff;
  margin: 5px 4px;
}
.logo .tag {
  background-color: red;
  padding: 3px;
  font-size: 12px;
  color: white;
  border-radius: 5px;
}
.logo div:nth-child(3) {
  margin: 2px;
}
.logo {
  overflow: hidden;
  margin-bottom: 5px;
}
.logo div {
  float: left;
  margin-right: 5px;
}
.data .grid-content div:first-child {
  color: #ff6900;
}
.data {
  margin-top: 10px;
}
.data .grid-content div {
  height: 40px;
  line-height: 40px;
  text-align: center;
}
/*scoped表示当前的样式只在当前的组件中有效，防止样式污染*/
.el-row {
  margin-bottom: 5px;
  /* &:last-child {
    margin-bottom: 0;
  } */
}
.el-col {
  border-radius: 4px;
  /* padding-right: 0; */
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #fdf5ef;
}
.bg-purple-light {
  background: #e5e9f2;
}
.data .grid-content {
  border-radius: 4px;
  min-height: 80px;
}
.table_data .grid-content {
  min-height: 60px;
  text-align: center;
  line-height: 60px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
</style>